solving 3x3 system of equations